<?php


namespace App\Transformers\Order;


use App\Models\OrderBatchLog;
use League\Fractal\TransformerAbstract;

class OrderBatchLogTransformer extends TransformerAbstract
{
    protected $availableIncludes = ['order'];

    public function transform(OrderBatchLog $data)
    {
        return [
            'id' => $data->id,
            'send' => $data->send ?? '',
            'send_success' => $data->send_success ?? '',
            'type' => $data->type ?? '',
            'status' => $data->status ?? '',
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : '',
            'deleted_at' => $data->deleted_at ? $data->deleted_at->format("Y-m-d H:i:s") : '',
        ];
    }

    /**
     * 订单用户信息
     */
    public function includeOrder(OrderBatchLog $batchLog)
    {
        return $this->collection($batchLog->order,new OrderTransformer());
    }

}
